#include "main/utils.h"
using namespace std;

class Solution {
public:
    vector<int> frequencySort(vector<int>& nums) {
      map<int, int> helper_map;
      for (int i = 0; i < nums.size(); ++i) {
        ++helper_map[nums[i]];
      }
      auto compare = [&](const int a, const int b) {
        if (helper_map[a] != helper_map[b])
          return helper_map[a] < helper_map[b];
        return a > b;
      };
      sort(nums.begin(), nums.end(), compare);
      return nums;
    }
};

int main() {
  vector<int> nums = {1, 1, 1, 2, 2, 2, 3};
  Solution su;
  auto ret = su.frequencySort(nums);
  printVec("leetcode1636", ret);

  return 0;
}
